# import pymysql as pSql
# from emmodels.em_basemodel import BaseModel
# from empatterns.em_singledirector import singleton
from sqlalchemy import create_engine
from sqlalchemy.schema import MetaData
# @singleton
# class SQLManager(object):
#
#     def __init__(self):
#         try:
#             self.connect = pSql.connect(host='localhost', port=3306, password='root', user='root', db='test',charset='GB2312')
#         except pSql.err.OperationalError:
#             raise pSql.err.OperationalError
#         self.cur = self.connect.cursor()
#
#     def close(self):
#         if self.cur != None:
#             self.cur.close()
#         if self.connect != None:
#             self.connect.close()
#
#     def update(self, sqlObj):
#         if isinstance(sqlObj, str):
#             self.cur.execute(sqlObj)
#         elif isinstance(sqlObj, BaseModel):
#             self.cur.execute(sqlObj.insertSQL())
#         self.connect.commit()

engine = create_engine('mysql+pymysql://root:root@localhost/EMV2?charset=utf8', encoding='utf8', echo=True)
metaData = MetaData(bind=engine)